﻿@namespace YwhWeb.Pages.Daily

<div class="unitView" style="text-align: right;">
    <Divider></Divider>
    <div class="left" style="min-width: 310px;">
         <PageContainer>
        <Content>   
            <Button @onclick="_=>NewDrawer()">添加记录</Button> 
            
            </Content>

        
            <ChildContent>
            <Table @ref="table"
                   TItem="YwhLib.Unit"
                   DataSource="@unitRsp.Items"
                   Total="_total"
                   @bind-PageIndex="_pageIndex"
                   @bind-PageSize="_pageSize"
                   @bind-SelectedRows="selectedRows"
                   OnChange="OnChange">
                <Selection Key="@(context.UnitNo.ToString())" />
                <AntDesign.Column Title="期号" @bind-Field="@context.PhaseNo" Sortable />
                <AntDesign.Column Title="楼号" @bind-Field="@context.BuildingNo" Sortable />
                <AntDesign.Column Title="单元号" @bind-Field="@context.UnitNo" Sortable />
                <AntDesign.Column Title="楼层数" @bind-Field="@context.FloorNum" Sortable/>
                <AntDesign.Column Title="每层房间数" @bind-Field="@context.RoomsPerFloor" Sortable/>
                <AntDesign.Column Title="户型面积" @bind-Field="@context.RoomArea" Sortable/>
                <ActionColumn Title="操作">
        <Space>
            <SpaceItem>
                <Button Danger OnClick=UpdateUnit>编辑</Button>
                <Button Danger OnClick=DeleteUnit>删除</Button>
                </SpaceItem>
        </Space>
    </ActionColumn>
            </Table>
            </ChildContent>
    </PageContainer>
    </div>
</div>

<Drawer Visible="this.drawerVisible" Width="400" OnClose="a=>{this.drawerVisible=false;}">
     <Title Level="4">添加单元</Title>
    <div>
    <p ></p>
 </div>

 <Text>选择期号楼号:</Text>
    <div>

<Select DataSource="@phaseOptions"
        @bind-Value="@editUnit.PhaseNo"
        ValueName="@nameof(Phase.PhaseNo)"
        LabelName="@nameof(Phase.PhaseNoS)"
        Style="width: 300px"
        Placeholder="请选择期号"
        AllowClear
        OnSelectedItemChanged="OnSelectedItemChangedHandler">
</Select>
<p></p>
<Select DataSource="@buildingOptions"
        @bind-Value="@editUnit.BuildingNo"
        ValueName="@nameof(Building.BuildingNo)"
        LabelName="@nameof(Building.BuildingNoS)"
        Style="width: 300px"
        Placeholder="请选择楼号"
        AllowClear>
</Select>
    <p></p>
</div>

<Text>单元号:</Text>
    <div>
    <Input Placeholder="请输入单元号" @bind-Value="@editUnit.UnitNo"  />
    <p></p>
</div>

<Text>楼层数:</Text>
    <div>
    <Input Placeholder="请输入楼层数" @bind-Value="@editUnit.FloorNum"  />
    <p></p>
</div>

<Text>每层房间数:</Text>
    <div>
    <Input Placeholder="请输入每层房间数" @bind-Value="@editUnit.RoomsPerFloor"  />
    <p></p>
</div>

<Text>户型面积:</Text>
    <div>
    <Input Placeholder="请输入户型面积" @bind-Value="@editUnit.RoomArea"  />
    <p></p>
</div>

<div style="text-align: right;">
    <Button Type="@ButtonType.Primary" OnClick=SaveUnit>保存</Button>
</div>
</Drawer>